package com.benyq.networkprogramme.email

import android.util.Log
import java.util.concurrent.Executors

/**
 * @author benyq
 * @date 18-9-25 17:47
 * @E-mail： 1520063035@qq.com
 * @description
 */
object SendMailUtil {


    //163
    private val HOST = "smtp.163.com"
    private val PORT = "25"
    private val FROM_ADD = "yezijian123456789@163.com"//发送方邮箱
    private val FROM_PSW = "88888888"//发送方邮箱授权码

//    //163
//    private static final String HOST = "smtp.163.com";
//    private static final String PORT = "465"; //或者465  994
//    private static final String FROM_ADD = "teprinciple@163.com";
//    private static final String FROM_PSW = "teprinciple163";
////    private static final String TO_ADD = "2584770373@qq.com";


    private val executorService = Executors.newSingleThreadExecutor()


    fun send(toAdd: String, subject: String, content: String){
        val mailInfo = createMail(toAdd, subject, content)
        val mailSender = MailSender()
        executorService.execute{
            val b = mailSender.sendTextMail(mailInfo)
            Log.e("susan", "susan$b")
        }
    }


    private fun createMail(toAdd: String, subject: String, content: String): MailInfo{
        return MailInfo(HOST, PORT, FROM_ADD, toAdd, FROM_ADD, FROM_PSW, subject, content)
    }


}